import 'package:get/get.dart';

import 'env/dev_env.dart';
import 'env/env_config.dart';
import 'env/prod_env.dart';
import 'env/staging_env.dart';

/// 应用环境类型
enum Flavor { dev, staging, prod }

/// 多环境配置管理
class FlavorConfig {
  // 单例实例
  static final FlavorConfig _instance = FlavorConfig._internal();
  static FlavorConfig get to => _instance;
  
  FlavorConfig._internal();
  
  // 当前环境
  late Flavor _flavor;
  late EnvConfig _config;
  
  // 初始化环境配置
  void init(Flavor flavor) {
    _flavor = flavor;
    switch (flavor) {
      case Flavor.dev:
        _config = DevEnv();
        break;
      case Flavor.staging:
        _config = StagingEnv();
        break;
      case Flavor.prod:
        _config = ProdEnv();
        break;
    }
  }
  
  // 获取当前环境
  Flavor get flavor => _flavor;
  
  // 获取当前环境配置
  EnvConfig get config => _config;
  
  // 是否为开发环境
  bool get isDevelopment => _flavor == Flavor.dev;
  
  // 是否为预发布环境
  bool get isStaging => _flavor == Flavor.staging;
  
  // 是否为生产环境
  bool get isProduction => _flavor == Flavor.prod;
} 